<script setup>
import { IconifyIconOnline } from "@/components/ReIcon";
import More2Fill from "@iconify-icons/ri/more-fill";
defineOptions({
  name: "ReCard"
});

const props = defineProps({
  product: {
    type: Object
  }
});

const emit = defineEmits(["EditTemplate", "FavoriteTemplate"]);

const handleEditTemplate = product => {
  emit("EditTemplate", product);
};
const handleFavoriteTemplate = product => {
  emit("FavoriteTemplate", product);
  console.log("FavoriteTemplate", product);
};
</script>

<template>
  <div class="list-card-item bg-bg_color">
    <div class="list-card-item_detail--img">
      <img
        style="height: auto; max-height: 100%"
        :src="product.canvasPicUrl"
        :alt="product.name"
      />
    </div>
    <div class="list-card-item_detail--name flex justify-between">
      <span> {{ product.name }}</span>
      <span>{{ product.width }}*{{ product.height }}</span>
    </div>
    <div class="prop">
      <el-dropdown trigger="click">
        <span class="iconsbox">
          <IconifyIconOffline :icon="More2Fill" class="icons" />
        </span>
        <template #dropdown>
          <el-dropdown-menu>
            <!-- <el-dropdown-item @click="handleEditTemplate(product)">
              <iconify-icon-online icon="ep:edit-pen" class="ml-1 mr-1" />
              编辑
            </el-dropdown-item> -->
            <el-dropdown-item @click="handleFavoriteTemplate(product)">
              <iconify-icon-online icon="ep:star" class="ml-1 mr-1" />
              复制到云端
            </el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>
  </div>
</template>

<style scoped lang="scss">
.btn {
  padding: 5px 25px;
  margin: 5px 0;
  font-size: 15px;
  border-right: 2px solid #e5e7ec;
}

.btn:last-child {
  border-right: 0 solid #e5e7ec;
}

.list-card-item {
  position: relative;
  display: flex;
  flex-direction: column;
  margin: 10px 0;
  overflow: hidden;
  cursor: pointer;
  border-radius: 5px;

  &_detail {
    flex: 1;
    min-height: 140px;
    padding: 15px 20px;

    &--name {
      padding: 0 10px;
      margin: 24px 0 8px;
      margin-top: 0;
      font-size: 14px;
      font-weight: 400;
    }

    &--img {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 100%;
      height: 200px;
      padding: 10px;
      margin-bottom: 10px;
      background-color: rgb(225 225 225);
    }
  }

  .prop {
    position: absolute;
    top: 8px;
    right: 0;
    z-index: 100;

    .icons {
      font-size: 0;
    }
  }
}

.list-card-item:hover {
  z-index: 2;
  // border: 1px solid #067bef !important;
  box-sizing: border-box;
  opacity: 1;
  transform: translateY(-5px);

  .iconsbox {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 18px;
    margin-right: 8px;
    font-size: 18px;
    font-weight: 400;
    line-height: 18px;
    color: #fff;
    text-align: center;
    cursor: pointer;
    background-color: #c6c6c6;
    border-radius: 4px;

    .icons {
      font-size: 22px;
    }
  }
}
</style>
